package videowarehouseapp;

import java.util.List;
import videostoreapp.ApplicationException;

public interface Stock {

    /**
     * The stock holding record for one video in one warehouse
     */
    public class StockInfo{
        public int id;              // unique stock holding id
        public int catalogue_id;	// which video
        public String warehouse;    // which warehouse
        public int holding;	        // how many copies are in stock

        public StockInfo(int id, int video_id, String warehouse, int holding)
        {
            this.id = id;
            this.catalogue_id = video_id;
            this.warehouse = warehouse;
            this.holding = holding;
        }
    }
    
    /**
     * Creates an item record (stock holding for a single video in a single 
     * warehouse) and returns its id
     * @param stock
     * @return
     */
    public int createItem(StockInfo stock);

    /**
     *  Modify attributes of the item record
     * @param stock
     */
    public void modifyItem(StockInfo stock);

    /**
     *  Deletes the item record by id
     * @param id
     */
    public void deleteItem(int id);

    /**
     * Decrement stock levels when videos are sold.
     * 
     * @param catalogue_id
     * @param quantity
     * @param warehouse
     * @return new stock level
     */
    public int sold(int catalogue_id, int quantity, String warehouse) throws ApplicationException;

    /**
     * Increment stock levels when new stock arrives. 
     * @param catalogue_id
     * @param quantity
     * @param warehouse
     * @return new stock level
     */
    public int bought(int catalogue_id, int quantity, String warehouse);

    /**
     * Retrieve an item record by its id
     * @param id
     * @return Item record or null if a record is not found
     */
    public StockInfo getItemById(int id);

    /**
     * Return a list of stock item records held by a warehouse
     * @param warehouse
     * @return List of stock item records. Will NOT return null.
     */
    public List<StockInfo> getItemByWarehouse(String warehouse);

    /**
     * Return holding of a stock item at a given warehouse
     * @param catalogue_id
     * @param warehouse
     * @return
     */
    public int getHoldingByWarehouse(int catalogue_id, String warehouse);
}
